<template lang="pug">
  kalix-dialog.user-add(title='添加' bizKey="liveRooms" ref="kalixBizDialog" v-bind:formModel.sync="formModel" v-bind:targetURL="targetURL" )
    div.el-form(slot="dialogFormSlot")
      <!--el-form-item.short(label="直播流地址" prop="liveUrl" v-bind:label-width="labelWidth" v-bind:rules="rules.liveUrl")-->
        <!--el-input(v-model="formModel.liveUrl") &lt;!&ndash; @keyup.native="proving"&ndash;&gt;-->
      <!--el-form-item.short(label="直播间ID" prop="liveId" v-bind:label-width="labelWidth" v-bind:rules="rules.liveId")-->
        <!--el-input(v-model="formModel.liveId")-->
      <!--el-form-item.short(label="直播间位置" prop="num" type="number" v-bind:label-width="labelWidth" v-bind:rules="rules.num")-->
        <!--el-input(v-model="formModel.num")-->
      <!--el-form-item.short(label="直播间名称" prop="liveName" v-bind:label-width="labelWidth" v-bind:rules="rules.liveName")-->
        <!--el-input(v-model="formModel.liveName")-->
      <!--el-form-item.short(label="用户ID" prop="userId" v-bind:label-width="labelWidth" v-bind:rules="rules.userId" class="none")-->
        <!--el-input(v-model="formModel.userId")-->
      <!--el-form-item(label="审核状态" prop="examine")-->
        <!--el-radio-group(v-model="formModel.examine")-->
          <!--el-radio(label="开播" value="开播")-->
          <!--el-radio(label="闭播" value="闭播")-->
      el-form-item.short(label="直播人名" prop="userName" v-bind:label-width="labelWidth" v-bind:rules="rules.userName")
         el-select(v-model="formModel.userId" placeholder="请选择" @change="getUid")
          el-option(v-for="item in options" v-bind:key="item.id" v-bind:label="item.name" v-bind:value="item.id")
      el-form-item.short(label="直播间名称" prop="liveName" v-bind:label-width="labelWidth" v-bind:rules="rules.liveName")
          el-input(v-model="formModel.liveName")

</template>

<script type="text/ecmascript-6">
  import {LiveRoomsURL} from '../../config.toml'
  import FormModel from './model'

  export default {
    name: 'LiveRoomsAdd',
    data() {
      return {
        formModel: Object.assign({}, FormModel),
        labelWidth: '170px',
        rules: {
          // doctor: [{required: true, message: '请输入坐班医生', trigger: 'change'}]
        },
        targetURL: LiveRoomsURL + '/addLiveRoom',
        options: []
      }
    },
    mounted() {
      this.getUname()
    },
    methods: {
      getUname() {
        this.axios.request({
          method: 'GET',
          url: '/camel/rest/users'
        }).then(res => {
          console.log('res========', res.data)
          this.options = res.data.data
        })
      },
      getUid(val) {
        let obj = {}
        obj = this.options.find((item) => {
          return item.id === val
        })
        this.formModel.userName = obj.name
        console.log('bbbbbbbbbbbbbbbbbbbbbb', this.formModel.userName)
      },
      proving() {
        this.formModel.liveUrl = this.formModel.liveUrl.replace(/[^\d]/g, '')
        this.formModel.liveUrl = this.formModel.liveUrl.replace('.', '')
      },
      proving1() {
        this.formModel.liveId = this.formModel.liveId.replace(/[^\d]/g, '')
        this.formModel.liveId = this.formModel.liveId.replace('.', '')
      },
      proving2() {
        this.formModel.userId = this.formModel.userId.replace(/[^\d]/g, '')
        this.formModel.userId = this.formModel.userId.replace('.', '')
      },
      init(dialogOption) {
        console.log('---------dialogOption------------', dialogOption)
      }
    }
  }
</script>

<style scoped lang="stylus" type="text/stylus">
  .el-form
    width 70%
    margin auto
    .el-input
      width 70%
    .radio
      margin-left 20px
      .el-radio
        color: #3465cb
        font-weight: bold
        font-size: 14px

  .none
    display none
</style>
